package pattern.state;

public class GumblallMashine
{
	State	soldOutState;
	State	noQuarterState;
	State	hasQuarterState;
	State	soldState;
	State	state	= soldOutState;
	int		count	= 0;
	public GumblallMashine(int numberGumballs)
	{
		soldOutState = new SoldOutState(this);
		noQuarterState = new NoQuarterState(this);
		hasQuarterState = new HasQuarterState(this);
		soldOutState = new SoldOutState(this);
		this.count = numberGumballs;
	}
	public void insertQuarter()
	{
		state.insertQuarter();
	}
	public void ejectQuarter()
	{
		state.ejectQuarter();
	}
	public void turnGrank()
	{
		state.turnCrank();
		state.dispense();
	}
	void setState(State state)
	{
		this.state = state;
	}
	State getState()
	{
		return this.state;
	}
	public State getSoldOutState()
	{
		return this.soldOutState;
	}
	public void setSoldOutState(State soldOutState)
	{
		this.soldOutState = soldOutState;
	}
	public State getNoQuarterState()
	{
		return this.noQuarterState;
	}
	public void setNoQuarterState(State noQuarterState)
	{
		this.noQuarterState = noQuarterState;
	}
	public State getHasQuarterState()
	{
		return this.hasQuarterState;
	}
	public void setHasQuarterState(State hasQuarterState)
	{
		this.hasQuarterState = hasQuarterState;
	}
	public State getSoldState()
	{
		return this.soldState;
	}
	public void setSoldState(State soldState)
	{
		this.soldState = soldState;
	}
	public int getCount()
	{
		return this.count;
	}
	public void setCount(int count)
	{
		this.count = count;
	}
	void releaseBall()
	{
		System.out.println("a gumball comes rolling out the slot...");
		if(count != 0)
		{
			count = count -1;
		}
	}
}
